
const requestURL = 'https://www.xiaolvtech.cn/api/web/';

var app =getApp();

const getRequestData = (requestName, paramet, callback) => {
  let token =app.globalData.token;
  console.log('请求token:'+token),
  wx.request({
    method: 'GET',
    url: requestURL+requestName,
    data: paramet,
    header: {
      'Authorization':'token '+token,
    },
    dataType: 'json',
    timeout: 1500,
    success (res) {
      if (res.statusCode ==200) {
        callback(true, res);
      } else {
        callback(false, res);
      }
    },
    fail (error) {
      callback(false, error);
    }
  })
}
const postRequestData = (requestName, paramet, callback) => {
  let token =app.globalData.token;
  console.log('请求token:'+token),
  wx.request({
    method: 'POST',
    url: requestURL+requestName,
    data: paramet,
    header: {
      'Authorization':'token '+token,
    },
    dataType: 'json',
    timeout: 1500,
    success (res) {
      if (res.statusCode ==200) {
        callback(true, res);
      } else {
        callback(false, res);
      }
    },
    fail (error) {
      callback(false, error);
    }
  })
}

module.exports = {
  getRequestData: getRequestData,
  postRequestData: postRequestData,
}